package pruebaVista;

import java.awt.EventQueue;


import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import Modelo.Lexema;
import Modelo.Simbolo;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.ImageIcon;

public class ViewTabla extends JFrame {

	private JTable table;

	public ViewTabla(Lexema lexema) {
		initialize(lexema);
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize(Lexema lexema) {

		setBounds(100, 100, 735, 433);
		
		getContentPane().setLayout(null);

		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(31, 76, 657, 285);
		getContentPane().add(scrollPane);

		table = new JTable();
		scrollPane.setViewportView(table);

		Object[][] data = new Object[lexema.objLexico.TablaSimbolos.size()][3];

		for (int i = 0; i < lexema.objLexico.TablaSimbolos.size(); i++) {
			data[i][0] = ((Simbolo) lexema.objLexico.TablaSimbolos.get(i))
					.getTokenId();
			data[i][1] = ((Simbolo) lexema.objLexico.TablaSimbolos.get(i))
					.getLexemaId();
			data[i][2] = ((Simbolo) lexema.objLexico.TablaSimbolos.get(i))
					.getTipo();
		}

		table.setModel(new javax.swing.table.DefaultTableModel(data,
		 new String[] { "Token", "Lexema", "WR" }));
				//new String[] { "Token", "Lexema" }));

		JLabel lblTablaDeTokens = new JLabel("Tabla de Tokens");
		lblTablaDeTokens.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 27));
		lblTablaDeTokens.setBounds(244, 30, 211, 35);
		getContentPane().add(lblTablaDeTokens);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon("C:\\ArchivosBaseCompilador\\tapiz.jpg"));
		label.setBounds(0, 0, 719, 394);
		getContentPane().add(label);
	}
}
